package com.smartsoft.fragments;

import android.app.Fragment;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.VideoView;
import com.smartsoft.R;

public class VideoFragment extends Fragment {

    private static final String RESOURCE_PREFIX = "android.resource://";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View videoFragment = inflater.inflate(R.layout.video_fragment, container);
        VideoView videoView = (VideoView) videoFragment.findViewById(R.id.video_view);
        if (videoView != null) {
            videoView.setVideoURI(getResourceUri(R.raw.big_bunny));
            videoView.start();
        }
        return videoFragment;
    }

    private Uri getResourceUri(int resIdentifier) {
        String resourcePath =  RESOURCE_PREFIX + getActivity().getPackageName() + "/" + resIdentifier;
        return Uri.parse(resourcePath);
    }


}
